﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="database.DAO, golf.Player, golf.Room"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>게임 대기 중</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
	function go_URL(url)
	{
        location.href = url;
	}
//-->
</SCRIPT>
</head>
<%
DAO dao = DAO.getInstance();
int roomNo = (Integer)session.getAttribute("roomNo");
int charNo = (Integer)session.getAttribute("charNo");
//boolean result = dao.playerOneShot(charNo, roomNo, 1 );
Player[] players = dao.getPlayerList(roomNo);
Player me = dao.getPlayer(roomNo, charNo);
Room room = dao.getRoom(roomNo);
%>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<span style="font-size:9pt;">
<h1>게임 대기중</h1>
<%if(players != null){ %>
	<form name="form1" method="post" action="gameResult.jsp">
		<%
		if( session.getAttribute("pre_player_status") == null ){
			session.setAttribute("pre_player_status", me);
		}
		
		
		%>
		<input type="hidden" name="enzi" value=<%=me.getCharacter().getEnzi() %>>
		<input type="hidden" name="exp" value=<%=me.getCharacter().getExp() %>>
		<input type="hidden" name="level" value=<%=me.getCharacter().getLevel() %>>
		<input type="hidden" name="high_distance" value=<%=me.getCharacter().getHigh_distance() %>>
		<input type="hidden" name="hole_in_one" value=<%=me.getCharacter().getHoleinone_cnt() %>>
		<table cellspacing="0" border="1" bordercolordark="white" bordercolorlight="black" width="80%">
	   		<tr>
	   			<td width="150">캐릭터명</td>
	   			<td width="80">모델명</td>
	   			<td width="50">등급</td>
	   			<td width="20">레벨</td>
	   			<td width="50">엔지</td>
	   			<td width="50">방장 여부</td>
			</tr>
		 	<%for( int i = 0; i < players.length; i++ ){ %>
			<tr>
				<td width="150"><%=players[i].getCharacter().getName() %></td>
	   			<td width="80"><%=players[i].getCharacter().getModel().getName() %></td>
	   			<td width="50"><%=players[i].getCharacter().getGrade().getName() %></td>
	   			<td width="20"><%=players[i].getCharacter().getLevel() %></td>
	   			<td width="50"><%=players[i].getCharacter().getEnzi() %></td>
	   			<td width="50"><%if(players[i].getCreater_yn()=='Y') out.println('Y');%>&nbsp;</td>
	   			
			</tr>	
			<%} %>
	   	</table>
	   	<%//방장이 게임시작을 눌러서 게임을 진행했다면,
	   	//즉 게임 결과가 나왔으면 그때부터 플레이어들은 결과보기 버튼을 볼 수 있다.
	   	if(room.getGame().getPlayYN()=='Y'){ %>
	   		<input type="submit" name="action" value="결과보기">
	   	<%} %>
	</form>
	<%
	//자신이 방 생성자라면 게임시작 버튼을 누를 수 있다.
	//게임시작 버튼을 누르면 playGame.jsp에서 게임을 전부 진행한다. 진행과정을 방장은 볼 수 있다.
	if(me.getCreater_yn() == 'Y'){ %>
		<input type="button" value="게임시작" onclick='go_URL("playGame.jsp"); return false;'>
	<%}%>
<%} %>
<input type="button" value="참가자 새로고침" onclick='go_URL("gameRoom.jsp"); return false;'>
</span>
</body>
</html>